package cn.fl.fgi.service.impl;

import cmm.mid.core.framework.page.Pager;
import cn.fl.fgi.api.IFgiPostResApiService;
import cn.fl.fgi.api.condition.FgiPostResQueryCondition;
import cn.fl.fgi.service.IFgiPostResService;
import cn.fl.fgi.vo.FgiPostResVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FgiPostResServiceImpl implements IFgiPostResService {
    @Autowired
    private IFgiPostResApiService fgiPostResApiService;
    @Override
    public Pager searchListPage(FgiPostResQueryCondition condition) {
        Pager page = new Pager();
        String dataStr = fgiPostResApiService.selectFgiPostResPage(condition);
        JSONObject jsonObject = JSON.parseObject(dataStr);
        List<FgiPostResVO> voList = JSON.parseArray(jsonObject.get("records").toString(), FgiPostResVO.class);
        page.setResultList(voList);
        page.setTotalCount(jsonObject.getInteger("total"));
        return page;
    }
}
